package com.lingxu.module.dataApi.controller;

import com.lingxu.base.common.api.vo.Result;
import com.lingxu.module.dataApi.entity.BatchParams;
import com.lingxu.module.dataApi.entity.DataApi;
import com.lingxu.module.dataApi.service.DataApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @Title: DataApiController
 * @Package: com.lingxu.module.dataApi.controller
 * @Author: ysj闫世杰
 * @Email: 1105324813@qq.com
 * @Date: Created in 2023/7/5 16:23
 * @Description:
 * @Version: 1.0.0
 */
@RestController
@RequestMapping(value = "/dataApi")
public class DataApiController {

    @Autowired
    private DataApiService dataApiService;

    //列表
    @RequestMapping(value = "/findApprovalList")
    public Result findApprovalList(Integer limit,Integer page){
        return dataApiService.findApprovalList(limit,page);
    }

    //批量审批
    @RequestMapping(value = "updateApproval")
    public Result updateApproval(@RequestBody BatchParams batchParams){
        String ids = batchParams.getIds();
        String[] split = ids.split(",");
        for(String id : split){
            DataApi dataApi = new DataApi();
            dataApi.setId(id);
            dataApi.setApprovalStatus(batchParams.getApprovalStatus());
            dataApi.setApprovalBy(batchParams.getApprovalBy());
            dataApi.setApprovalTime(new Date());
            dataApiService.updateById(dataApi);
        }
        return Result.ok("操作成功");
    }
}
